<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<link rel="shortcut icon" href="img/logo.ico" />
		<title>修改密码</title>
		<link rel="stylesheet" href="bootstrap/css/bootstrap.css" />
		<link rel="stylesheet" href="css/style.css" />
		<script src="js/jquery.min.js"></script>
		<script type="text/javascript" src="bootstrap/js/bootstrap.min.js" ></script>
	</head>

	<body>
		<link rel="stylesheet" href="css/nav.css" />
		<div class="container-fluid">
			<div class="row">
				  <!-- <div class="col-md-3"></div> -->
					<div class="col-md-4 col-md-offset-4 login-box">

							<br>
							<img src="images/logo.png" alt="" class="logo-img">
							<br>

							<br>

							<br>
							<form id="login" onkeydown="if(event.keyCode==13){return false;}">
									<!-- <div class="form-group form-group-lg">
											<label for="phone" class="sr-only">用户名</label>
											<div class="input-group">
													<div class="input-group-addon">
															<span class="glyphicon glyphicon-user"></span>
													</div>
													<input type="text" name="userId" placeholder="请输入用户名" id="userId" class="form-control">
											</div>
									</div> -->
									<div class="form-group form-group-lg">
											<label for="password" class="sr-only">旧密码</label>
											<div class="input-group">
													<div class="input-group-addon">
															<span class="glyphicon glyphicon-lock"></span>
													</div>
													<input type="password" autocomplete="new-password" name="oldPassword" placeholder="请输入旧密码" id="oldPassword" class="form-control">
											</div>
									</div>
									<div class="form-group form-group-lg">
											<label for="password" class="sr-only">新密码</label>
											<div class="input-group">
													<div class="input-group-addon">
															<span class="glyphicon glyphicon-lock"></span>
													</div>
													<input type="password" autocomplete="new-password" name="newPassword" placeholder="请输入新密码" id="newPassword" class="form-control">
											</div>
									</div>

									<button type="button" class="btn btn-warning btn-lg btn-block" id="passBtn">确认提交</button>
							</form>
					</div>
			</div>
	</div>

	</body>
</html>
<script type="text/javascript" src="plugin/fromRegxp/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="js/cookie.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/login.js"></script>
<script src="js/md5.min.js"></script>
<script type="text/javascript" src="plugin/layer/layer.js"></script>
<script type="text/javascript">
		$('#passBtn').click(function(){
			// var userId = $('#userId').val();
			var oldPassword = $('#oldPassword').val();
			var newPassword = $('#newPassword').val();
			//var tname = /^[0-9a-zA-Z_]{6,16}$/;                  //用户名只能由字母、数字、下划线组成（6-16位）
			// if (!tname.test(userId)) {
			// 	layer.msg('用户名只能由字母、数字、下划线组成（6-16位）')
			// 	$('#userId').focus()
			// 	return false;
			// }
			// if (oldPassword == '') {
		    //     layer.msg('旧密码不能为空');
			// 		$('#oldPassword').focus()
		    //     return false;
	        // }
			// if (newPassword == '') {
		    //     layer.msg('新密码不能为空');
			// 		$('#newPassword').focus()
		    //     return false;
		    // }
		    console.log(navListData.adminId)
			var data = {
				'userId':navListData.adminId,
				'oldPassword':md5(oldPassword),
				'newPassword':md5(newPassword)
			}
			$.post(serverURL+'/password/edit',data,function(data){
				console.log(data)
				layer.msg(data.msg)
				if (data.code == 200) {
					layer.msg(data.msg)
					setTimeout("window.location.href = 'login.html'",2000)
				}else if(data.code == 400){
					alert("登陆超时请重新登陆")
					window.location.href = "login.html";
				}
			})
		})
</script>
